package com.howtoplay.data.mapper;

import Bean.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import java.util.List;


public interface UserMapper {
    @Select("select * from user order by create_time limit 0,10")
    @Results({
            @Result(property = "userId",column = "user_id",javaType = java.lang.String.class,jdbcType = JdbcType.VARCHAR),
            @Result(property = "userName",column = "user_name",javaType = java.lang.String.class,jdbcType = JdbcType.VARCHAR),
            @Result(property = "sex",column = "sex",javaType = java.lang.Boolean.class,jdbcType = JdbcType.TINYINT),
            @Result(property = "openId",column = "open_id",javaType = java.lang.String.class,jdbcType = JdbcType.VARCHAR),
            @Result(property = "createTime",column = "create_time",javaType = java.lang.String.class,jdbcType = JdbcType.TIMESTAMP),
            @Result(property = "phoneNum",column = "phone_num",javaType = java.lang.String.class,jdbcType = JdbcType.VARCHAR),
            @Result(property = "userImg",column = "user_img",javaType = java.lang.String.class,jdbcType = JdbcType.VARCHAR),
            @Result(property = "introduct",column = "introduct",javaType = java.lang.String.class,jdbcType = JdbcType.VARCHAR)
    })
    List<User> selectUser();

    @Select("select * from user where user_id = #{id}")
    @Results({
            @Result(property = "userId",column = "user_id",javaType = java.lang.String.class,jdbcType = JdbcType.VARCHAR),
            @Result(property = "userName",column = "user_name",javaType = java.lang.String.class,jdbcType = JdbcType.VARCHAR),
            @Result(property = "sex",column = "sex",javaType = java.lang.Boolean.class,jdbcType = JdbcType.TINYINT),
            @Result(property = "openId",column = "open_id",javaType = java.lang.String.class,jdbcType = JdbcType.VARCHAR),
            @Result(property = "createTime",column = "create_time",javaType = java.lang.String.class,jdbcType = JdbcType.TIMESTAMP),
            @Result(property = "phoneNum",column = "phone_num",javaType = java.lang.String.class,jdbcType = JdbcType.VARCHAR),
            @Result(property = "userImg",column = "user_img",javaType = java.lang.String.class,jdbcType = JdbcType.VARCHAR),
            @Result(property = "introduct",column = "introduct",javaType = java.lang.String.class,jdbcType = JdbcType.VARCHAR)
    })
    User seletUserById(String id);
}
